<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="checkbox" name="test" value="swimming" /> (去游泳)
    <input type="checkbox" name="test" value="shopping" />(去购物)
    <input type="checkbox" name="test" value="books" />看书
    <input type="checkbox" name="test" value="playing computer games" /> (玩电脑游戏)
    <input type="checkbox" name="test" value="watching TV " />(看电视)
    <input type="checkbox" name="test" value="    eatting food" /> (吃⾷物)
    <input type="checkbox" name="test" value="reading" /> 阅读
    <button onclick="fn()">提交选中的复选框</button>

    <script>
        function fn() {
            var ipt = document.querySelectorAll('input')
            var arr = []
            for (var i = 0; i < ipt.length; i++) {

                if (ipt[i].checked) {
                    arr.push(ipt[i].value)
                }
            }
            console.log(arr, '选择的复选框');
        }
    </script>
</body>

</html>